package com.yunhe.mybatis.web.pay;

import com.yunhe.mybatis.dto.Pageable;
import com.yunhe.mybatis.service.PayService;
import com.yunhe.mybatis.service.UserService;
import com.yunhe.mybatis.service.impl.PayServiceImpl;
import com.yunhe.mybatis.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/pay")
public class listServlet extends HttpServlet {
    private PayService payService = new PayServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //获取分页参数
        String page = req.getParameter("page");
        String size = req.getParameter("size");

        int intPage =  null != page ? Integer.parseInt(page) : 1;
        int intSize = null != size ? Integer.parseInt(size) : 5; //页面m默认的大小

        Pageable pageable = payService.findforPage(intPage,intSize);
        req.setAttribute("pageable",pageable);

        req.getRequestDispatcher("/WEB-INF/pay/select.jsp").forward(req,resp);
    }

}
